package threadDemo1.isAlive;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 38917
 * Date: 2025-02-26
 * Time: 22:27
 */
public class ThreadDemo {
    public static void main(String[] args) {
        Thread thread = new Thread(()->{
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });
        //false,线程还没启动
        System.out.println(thread.isAlive());

        thread.start();
        //true,线程正在执行任务
        System.out.println(thread.isAlive());

        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        //false,线程结束
        System.out.println(thread.isAlive());
    }
}
